package com.ht.medicaltreatment.activity.haocai2

import android.text.TextUtils
import android.widget.CheckBox
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.ht.medicaltreatment.R
import com.ht.medicaltreatment.bean.PrepareData

class CreateConsumableTopAdapter : BaseQuickAdapter<PrepareData,BaseViewHolder>(R.layout.item_creat_consumable_top_layout){

    init {
        addChildClickViewIds(R.id.cbAll,R.id.tvBoxName,R.id.tvRFID,R.id.tvLocation)
    }

    override fun convert(holder: BaseViewHolder, item: PrepareData) {
        holder.setText(R.id.tvPosition,"${getItemPosition(item)+1}、")
        holder.setText(R.id.tvBoxName,item.name)
        holder.setText(R.id.tvRFID,item.rfidCode)
        holder.setText(R.id.tvLocation,item.position)
        holder.setText(R.id.tvGuiGe,item.sampleStru)
        val checkBox = holder.getView<CheckBox>(R.id.cbAll)
        if(!TextUtils.isEmpty(item.rfidCode)){
            checkBox.isEnabled = false
        }else{
            checkBox.isEnabled = true
        }
        checkBox.isChecked = item.isChecked
    }
}
